package com.lzh.hospital.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzh.hospital.mapper.HospitalMapper;
import com.lzh.hospital.service.HospitalService;
import com.lzh.model.Hospital;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Author:L枣
 * Date:2024/8/22
 */
@Service
@AllArgsConstructor
public class HospitalServiceImpl
        extends ServiceImpl<HospitalMapper, Hospital>
        implements HospitalService {

    private final HospitalMapper hospitalMapper;


    @Override
    public List<Hospital> pageList(Hospital hospital, Page page) {
        QueryWrapper<Hospital> queryWrapper = new QueryWrapper<>();
        if (hospital.getChineseName()!=null&&!hospital.getChineseName().equals(""))
            queryWrapper.like("chinese_name",hospital.getChineseName());
        if (hospital.getAddress()!=null&&!hospital.getAddress().equals(""))
            queryWrapper.like("address",hospital.getAddress());
        if (hospital.getHospitalLevel()!=null&&!hospital.getHospitalLevel().equals(""))
            queryWrapper.like("hospital_level",hospital.getHospitalLevel());
        if (hospital.getIsInsurance()!=null)
            queryWrapper.eq("is_insurance",hospital.getIsInsurance());

        return hospitalMapper.selectPage(page, queryWrapper).getRecords();

    }
}
